package com.s3.s3demo.minio;

import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.model.ListObjectsRequest;
import software.amazon.awssdk.services.s3.model.ListObjectsResponse;
import software.amazon.awssdk.services.s3.model.PutObjectRequest;

import java.nio.file.Path;

/**
 * 上传文件到存储桶
 */
public class PutObjects extends MinioAuth {

    public static void main(String[] args) {
        try (S3Client s3Client = generateS3Client()) {
            //上传文件
            s3Client.putObject(PutObjectRequest.builder().bucket("kestra").key("kestra.yaml").build(),
                    Path.of("F:\\s3test\\kestra.yaml"));

            //查询文件
            ListObjectsResponse response = s3Client.listObjects(ListObjectsRequest.builder().bucket("kestra").prefix("kestra.yaml").build());
            response.contents().forEach(System.out::println);
        }
    }

}
